package photogcalc.common;

/**
 *
 * @author okkonena
 */
public class FstopSlider extends Slider {

    protected double stops[] = { 
        0.95, 1.0, 1.1, 1.2, 1.4,
        1.6, 1.8, 2.0, 2.2, 2.5,
        2.8, 3.2, 3.5, 4, 4.5,
        5.0, 5.6, 6.3, 7.1, 8,
        9, 11, 13, 14, 16,
        18, 20, 22, 32, 45,
        64, 90, 128
    };
    
    protected FstopSlider(String label, double min, double max) {
        super(label, min, max);
    }

    public FstopSlider(String label) {
        this(label, 0, 32);
    }

    /** Returns fstop value */
    public double getValue() {
        return stops[(int)super.getValue()];
    }

    /** Sets fstop value. If fstop is not found then this does nothing. */
    public void setValue(double val) {
        // according to Nokia, looping is better this way
        for (int i = 0, n = stops.length; i < n; i++)
            if (stops[i] == val)
                super.setValue(i);
    }

    protected String getValueStr() {
        return "F/"+this.getValue();
    }
}
